package javavis.jip3d.gui;

import javavis.base.ParamType;

public class FunctionParam {

	/**
	 * @uml.property  name="iminvalue"
	 */
	public int iminvalue;
	/**
	 * @uml.property  name="imaxvalue"
	 */
	public int imaxvalue;
	/**
	 * @uml.property  name="dminvalue"
	 */
	public double dminvalue;
	/**
	 * @uml.property  name="dmaxvalue"
	 */
	public double dmaxvalue;
	/**
	 * @uml.property  name="dstep"
	 */
	public double dstep;

	/**
	 * @uml.property  name="ivalue"
	 */
	private int ivalue;
	/**
	 * @uml.property  name="rvalue"
	 */
	private double rvalue;
	/**
	 * @uml.property  name="svalue"
	 * @uml.associationEnd  
	 */
	private String svalue;
	/**
	 * @uml.property  name="lsvalue" multiplicity="(0 -1)" dimension="1"
	 */
	private String lsvalue[];
	/**
	 * @uml.property  name="bvalue"
	 */
	private boolean bvalue;
	/**
	 * @uml.property  name="sdvalue"
	 * @uml.associationEnd  
	 */
	private ScreenData sdvalue;
	/**
	 * @uml.property  name="ovalue"
	 */
	private Object ovalue;

	/**
	 * @uml.property  name="name"
	 */
	public String name;
	/**
	 * @uml.property  name="type"
	 * @uml.associationEnd  multiplicity="(1 1)"
	 */
	public ParamType type;

	public FunctionParam(String n, ParamType t)
	{
		name = n;
		type = t;
		rvalue = ivalue = 0;
		svalue = "";
		lsvalue = null;
		bvalue = false;
		sdvalue = null;

		iminvalue = Integer.MIN_VALUE;
		imaxvalue = Integer.MAX_VALUE;
		dminvalue = -Double.MAX_VALUE;
		dmaxvalue = Double.MAX_VALUE;
		dstep = 0.5;
		ovalue = null;
	}

	public void setValue(int val)
	{
		if(type==ParamType.INT)
		{
			ivalue = val;
		}
		else
		{
			System.err.println("FunctionParam::setValue<int> Error: Can not assing int to " + type+ " ("+val+")");
		}
	}

	public void setValue(double val)
	{
		if(type==ParamType.FLOAT)
		{
			rvalue = val;
		}
		else
		{
			System.err.println("FunctionParam::setValue<double> Error: Can not assing double to " + type+ " ("+val+")");
		}
	}

	public void setValue(String val)
	{
		if(type==ParamType.STRING || type==ParamType.FILE || type==ParamType.DIR || type==ParamType.LIST)
		{
			svalue = val;
		}
		else
		{
			System.err.println("FunctionParam::setValue<String> Error: Can not assing String to " + type+ " ("+val+")");
		}
	}
	public void setValue(String val[])
	{
		if(type==ParamType.LIST)
		{
			lsvalue = val;
		}
		else
		{
			System.err.println("FunctionParam::setValue<String> Error: Can not assing String[] to " + type+ " ("+val+")");
		}
	}

	public void setValue(boolean val)
	{
		if(type==ParamType.BOOL)
		{
			bvalue = val;
		}
		else
		{
			System.err.println("FunctionParam::setValue<int> Error: Can not assing boolean to " + type+ " ("+val+")");
		}
	}

	public void setValue(ScreenData val)
	{
		if(type==ParamType.SCRDATA)
		{
			sdvalue = val;
		}
		else
		{
			System.err.println("FunctionParam::setValue<int> Error: Can not assing ScreenData to " + type+ " ("+val+")");
		}
	}


	public void setValue(Object val)
	{
		if(type==ParamType.OBJECT)
		{
			ovalue = val;
		}
		else
		{
			System.err.println("FunctionParam::setValue<object> Error: Can not assing Object to " + type);
		}
	}
	public int getValueInt()
	{
		return ivalue;
	}

	public double getValueReal()
	{
		return rvalue;
	}

	public String getValueString()
	{
		return svalue;
	}

	public boolean getValueBool()
	{
		return bvalue;
	}

	public ScreenData getValueScrData()
	{
		return sdvalue;
	}
	
	public String [] getValueList()
	{
		return lsvalue;
	}

	public Object getValueObject()
	{
		return ovalue;
	}
}
